﻿#ifndef COMMON_H
#define COMMON_H


#include <string>
#include <vector>
#include "json11.hpp"

// 商品信息
typedef struct _commodity {
    int id;
    std::string name;
    std::string picture;
    std::string price;
    std::string amount;
} commodity;

// 订单项
typedef struct _order_item {
    int id;
    std::string name;
    std::string price;
    int num;
} orderItem;

// 用户信息
typedef struct _member {
    int id;
    std::string account;
    std::string password;
    std::string name;
    std::string sex;
    std::string email;
    std::string phone;
    std::string level;
    std::string address;
} member;

extern std::vector<orderItem *> order;  // 订单，<商品信息,数量>
extern member currentMember;  // 当前登录用户

class Common {
  public:
    Common();
    static std::string getValueStr(std::string *msg, const char *key); // 从json中获取指定key的string value
    static int getValueInt(std::string *msg, const char *key); // 从json中获取指定key的int value
};

#endif // COMMON_H
